package com.jiaomatech.demo.user.fallback;

import com.jiaomatech.demo.user.dto.UserDto;
import com.jiaomatech.demo.user.feign.UserSearchFeign;
import feign.hystrix.FallbackFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.ResponseEntity;

/**
 * Description: Fallback .<br>
 *
 * @author jm
 *     created by 2019/10/18
 */
public class UserSearchFallback implements FallbackFactory<UserSearchFeign> {
    private final static Logger logger = LoggerFactory.getLogger(UserSearchFallback.class);

    @Override
    public UserSearchFeign create(Throwable throwable) {
        return new UserSearchFeign() {

            @Override
            public ResponseEntity<UserDto> findUserById(String userId) {
                logger.error("[用户服务] - [查询用户信息] - [异常]", throwable);
                return null;
            }
        };
    }
}